#ifndef __OBJECT_DETECTOR_HPP__
#define __OBJECT_DETECTOR_HPP__


#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/features2d.hpp"     // SURF & SIFT headers have been moved here!!!!
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc/imgproc_c.h"

#include <iostream>
#include <vector>
#include <stdio.h>

//#include "global.h"

#include "MatWork.hpp"

// original modification from OpenCV Sample
//int callSIFTMatch(const cv::Mat Img, const cv::Mat Obj);
int callSIFTMatch(const cv::Mat ref_img, const cv::Mat frame);

// without returning correspondence
//int callSIFTMatch(cv::Mat test_img, cv::Mat descriptors_obj, std::vector<cv::KeyPoint> keypoints_obj, cv::Mat obj_img);
int callSIFTMatch(cv::Mat frame, cv::Mat descriptors_ref, std::vector<cv::KeyPoint> keypoints_ref, cv::Mat ref_img);

// returning correspondence
int callSIFTMatch(cv::Mat test_img, cv::Mat descriptors_obj, std::vector<cv::KeyPoint> keypoints_obj, cv::Mat obj_img, 
				  std::vector<cv::KeyPoint> keypoints_img_ret, std::vector<cv::DMatch> enh_good_matches_ret);

// returning correspondence with both parameters
// int callSIFTMatch(cv::Mat test_img, cv::Mat descriptors_obj, std::vector<cv::KeyPoint> keypoints_obj, cv::Mat obj_img, 
//				  std::vector<cv::KeyPoint>& keypoints_img_ret, cv::Mat& descriptors_img_ret, std::vector<cv::DMatch>& enh_good_matches_ret);
int callSIFTMatch(cv::Mat frame, cv::Mat descriptors_ref, std::vector<cv::KeyPoint> keypoints_ref, cv::Mat ref_img, 
				  std::vector<cv::KeyPoint>& keypoints_img_ret, cv::Mat& descriptors_img_ret, std::vector<cv::DMatch>& enh_good_matches_ret);   // BUG somewhere in here!!!! -> DONE

int ObjectDetect(const cv::Mat test_img, 
				 std::vector<std::vector<std::vector<cv::KeyPoint>>> db_keypoints, 
				 std::vector<std::vector<cv::Mat>> db_descriptors, 
				 std::vector<std::vector<cv::Mat>> hier_db_img);

void XtractMatchingPoints(const std::vector<cv::KeyPoint>& keypoints_obj, const std::vector<cv::KeyPoint>& keypoints_img, const std::vector<cv::DMatch>& matches,
						  cv::Mat& matched_pnts_obj, cv::Mat& matched_pnts_img);

#endif